﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using ClientLib.Common;
namespace WpfDataBingding.FramePanel
{
    /// <summary>
    /// LoginPage.xaml 的交互逻辑
    /// </summary>
    public partial class LoginPage : Page
    {
        public LoginPage()
        {
            InitializeComponent();
           
        }

        private void buttonReset_Click(object sender, RoutedEventArgs e)
        {
            this.username.Text = string.Empty;
            this.userpassword.SecurePassword.Clear();
        }

        private void buttonLogin_Click(object sender, RoutedEventArgs e)
        {
           
            string username = this.username.Text.ToString();
            IntPtr pass = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(this.userpassword.SecurePassword);
            string userpassword = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(pass);


            Application.Current.Properties["UserName"] = username;

            
            if (CheckLogin(username, userpassword))
            {

                MonitorStart.InitData();
                this.NavigationService.Navigate(new MainPage());
            }
            // this.userpassword.set = new System.Security.SecureString();
        }


        private bool CheckLogin(string user,string pass)
        {
            return true;
        }
    }
}
